package com.hzncc.flowable_diboot.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hzncc.flowable_diboot.contract.entity.ContractAudit;
import com.diboot.core.mapper.BaseCrudMapper;
import com.hzncc.flowable_diboot.contract.vo.ContractAuditPageReqVO;
import com.hzncc.flowable_diboot.contract.vo.ContractAuditVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* 合同审批 相关Mapper层接口定义
* @author MyName
* @version 1.0
* @date 2024-07-12
* Copyright © MyCorp
*/
@Mapper
public interface ContractAuditMapper extends BaseCrudMapper<ContractAudit> {
    IPage<ContractAuditVO> selectContractList(IPage page, @Param("reqVO")ContractAuditPageReqVO reqVO);
    
    List<ContractAuditVO> selectHistoryContractList(@Param("reqVO") ContractAuditVO reqVO);

    String selectLastVersionContract(@Param("contractCode") String contractCode);

    @Select("SELECT mca.id FROM mdl_contract_audit mca left join mdl_contract_audit_iam_user mcaiu on mca.id = mcaiu.contract_audit  WHERE mcaiu.user = #{userId} and mca.is_deleted = 0 and mcaiu.is_deleted = 0")
    List<String> getStarContractIds(String userId);
}